package com.ruyuan.eshop.order.wms;

import com.ruyuan.eshop.common.enums.OrderStatusEnum;
import com.ruyuan.eshop.order.dao.OrderDeliveryDetailDAO;
import com.ruyuan.eshop.order.domain.dto.WmsShipDTO;
import com.ruyuan.eshop.order.domain.entity.OrderDeliveryDetailDO;
import com.ruyuan.eshop.order.domain.entity.OrderInfoDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lxg
 * @Description:订单已出库物流结果处理器
 * @date 2022/4/822:17
 */
@Component
public class OrderOutStockedProcessor extends AbstractWmsShipResultProcessor {
    @Autowired
    private OrderDeliveryDetailDAO orderDeliveryDetailDAO;
    @Override
    protected void doExecute(WmsShipDTO wmsShipDTO, OrderInfoDO orderInfoDO) {
        //增加订单配送表的出库时间
        OrderDeliveryDetailDO deliveryDetail = orderDeliveryDetailDAO.getByOrderId(orderInfoDO.getOrderId());
        orderDeliveryDetailDAO.updateOutStockTime(deliveryDetail.getId(),wmsShipDTO.getOutStockTime());

    }

    @Override
    protected boolean checkOrderStatus(OrderInfoDO orderInfoDO) {
        OrderStatusEnum orderStatusEnum=OrderStatusEnum.getByCode(orderInfoDO.getOrderStatus());
        if (!OrderStatusEnum.FULFILL.equals(orderStatusEnum)){
            return false;

        }
        return true;
    }
}
